package com.ruoyi.gis.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.gis.domain.Area;
import com.ruoyi.gis.service.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/gis/area")
public class AreaController extends BaseController {

    @Autowired
    private IAreaService areaService;


    @GetMapping("/list/areas")
    public AjaxResult listAreas(Area area)
    {

        List<Area> list = areaService.selectAreaList(area);
        return AjaxResult.success(list);
    }


    @GetMapping("/list/province/")
    public AjaxResult listAllProvince()
    {

        List<Area> list = areaService.selectProvinceList();
        return AjaxResult.success(list);
    }

    @GetMapping("/list/city/{province}")
    public AjaxResult listAllCity(@PathVariable("province") String province)
    {

        List<Area> list = areaService.selectCityList(province);
        return AjaxResult.success(list);
    }

    @GetMapping("/list/district/{province}/{city}")
    public AjaxResult listAllDistrict(@PathVariable("province") String province,
                                      @PathVariable("city") String city)
    {

        List<Area> list = areaService.selectDistrictList(province,city);
        return AjaxResult.success(list);
    }

}
